﻿using System;
using System.Collections.Generic;
using System.Text;
using SharpDiary.Core.Data;

namespace SharpDiary.Core.ORMapping
{
    /// <summary>
    /// 模块设置。
    /// </summary>
    [TableInfoAttribute("ModuleSettingsInfo")]
    public class ModuleSettingsInfo : DbMappingObjectBase
    {
        #region Fields & Properties

        private string _id = string.Empty;

        [FieldMapping(true, System.Data.DbType.String, false, true)]
        public string Id
        {
            get { return _id; }
            set { _id = value; }
        }

        private string _assemblyString = string.Empty;

        [FieldMapping(true, System.Data.DbType.String, false, false)]
        public string AssemblyString
        {
            get { return _assemblyString; }
            set { _assemblyString = value; }
        }

        private string _name = string.Empty;

        [FieldMapping(true, System.Data.DbType.String, false, false)]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        private string _description = string.Empty;

        [FieldMapping(true, System.Data.DbType.String, false, false)]
        public string Description
        {
            get { return _description; }
            set { _description = value; }
        }

        private Int64 _sortId = 9999;

        [FieldMapping(true, System.Data.DbType.Int64, false, false)]
        public Int64 SortId
        {
            get { return _sortId; }
            set { _sortId = value; }
        }

        #endregion

        #region Constructors

        public ModuleSettingsInfo() { }

        #endregion

        #region Methods

        public override string ToString()
        {
            return (!string.IsNullOrEmpty(_name) ? _name : string.Empty);
        }

        /// <summary>
        /// 获取所有模块设置信息。
        /// </summary>
        /// <returns></returns>
        public static List<ModuleSettingsInfo> GetAllModuleSettingsInfo()
        {
            StringBuilder sql = new StringBuilder();
            sql.AppendLine("select * from ModuleSettingsInfo");
            sql.AppendLine("order by SortId");

            return DbObjectMappingHelper.QueryObjectList<ModuleSettingsInfo>(sql.ToString());
        }

        #endregion
    }
}
